#packages
for (x in c("dplyr", "ggplot2","readxl","plotly"
,"psych", "ggfortify")) {
library(x, character.only = TRUE)
}
datos<- read_excel("/Users/Juan Alfredo.DESKTOP-ETJ31JC/Documents/Universidad/Termino 2020 2S/R Samples/Pagina/PIB Argentina_1.xlsx")
dt<- datos[,c(2,4,10,13)]
dt %>% mutate(m= import/PIB) %>% mutate(x= export/PIB)
## # A tibble: 114 x 6
## PIB import export ITCRM m x
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 391657. 55833. 45376. NA 0.143 0.116
## 2 437818. 55469. 51528. NA 0.127 0.118
## 3 439218. 64247. 48417. NA 0.146 0.110
## 4 443720. 69336. 47327. NA 0.156 0.107
## 5 421660. 75389. 47985. NA 0.179 0.114
## 6 466065. 71189. 58228. NA 0.153 0.125
## 7 458808. 74677. 57721. NA 0.163 0.126
## 8 465820. 75378. 58182. NA 0.162 0.125
## 9 430752. 74600. 62896. NA 0.173 0.146
## 10 449080. 61634. 78021. NA 0.137 0.174
## # ... with 104 more rows
colnames(datos)
## [1] "PIB_93" "PIB" "import_93" "import"
## [5] "consum_priv93" "consump_priv" "consum_pub93" "consump_pub"
## [9] "export_93" "export" "FBK_93" "fbkf"
## [13] "ITCRM" "PI_export" "PI_Import"
fechas<- c("1993-01-01", "2021-06-20")
st<- as.Date(fechas[1])
end<- as.Date(fechas[2])
time<- seq(st, end, by= "quarter")
# Create a xts object
datos<- as.ts(datos)
p1<- datos %>% ggplot(aes(x=time, y= PIB)) +
geom_line(linetype = "dashed", color= "blue") +
theme( axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.background = element_blank()) +
labs(title = "Gross Domestic Product (GDP)",
subtitle = "1993-2021",
caption = "Source: Indec") + scale_y_log10()
ggplotly(p1)
p2<- datos %>% ggplot(aes(x=time, y= import)) +
geom_line(linetype = "dashed", color= "brown") +
theme( axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.background = element_blank()) +
labs(title = "Imports ",
subtitle = "1993-2021",
caption = "Source: Indec") + scale_y_log10()
ggplotly(p2)
p3<- datos %>% ggplot(aes(x=time, y=consump_pub )) +
geom_line(linetype = "dashed", color= "brown") +
theme( axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.background = element_blank()) +
labs(title = "Public consumption ",
subtitle = "1993-2021",
caption = "Source: Indec") + scale_y_log10()
ggplotly(p3)
m is the ratio of imports to GDP.
x is the ratio of export to (domestic) GDP
dt1<- dt %>% mutate(m= import/PIB) %>% mutate(x= export/PIB)
p4<- dt1 %>% ggplot(., aes(x= ITCRM, y= m)) + geom_point()+
geom_smooth(method = "lm") + scale_y_log10() + scale_x_log10()
ggplotly(p4)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 18 rows containing non-finite values (stat_smooth).
p5<- dt1 %>% ggplot(., aes(x= ITCRM, y= x)) + geom_point()+
geom_smooth(method = "lm") + scale_y_log10() + scale_x_log10()
ggplotly(p5)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 18 rows containing non-finite values (stat_smooth).
corPlot(dt, cex = 1.2)